class Path {
  int posX, posY, pWidth, pHeight;
  int[] input_flags = new int[4];
  PImage brick_h;
  PImage brick_v;
  String direction;
  
Path(int posX, int posY, int pWidth, int pHeight, String direction, PImage brick) {
  this.posX = posX;
  this.posY = posY;
  this.pWidth = pWidth;
  this.pHeight = pHeight;
  this.direction = direction;
  
  if (direction == "v") 
    this.brick_v = brick;
  else 
    this.brick_h = brick;
  drawTexture(direction);
  //rect(posX,posY,pWidth,pHeight);
  //fill(255,0,0);
}  

void drawTexture(String direction){
  PImage brick = brick_h;
 
  if (direction == "v")
    brick = brick_v;
  else 
    brick = brick_h;
    
  beginShape();
  texture(brick);
  vertex(posX, posY, 0, 0);
  vertex(posX + pWidth, posY, brick.width, 0);
  vertex(posX + pWidth, posY + pHeight, brick.width, brick.height);
  vertex(posX, posY + pHeight, 0, brick.height);
  endShape(); 
  
}

void collision(int xpos,int ypos, int animationHeight, int animationWidth) {
  //Collision in vertical paths
  if(direction == "v"){
    //Rectangle left edge with character left edge
    if((xpos < posX) || (xpos == posX )) 
      input_flags[1] = 1;
    //Rectangle right edge with character right edge
    if(((xpos + animationWidth) > (posX + pWidth))||((xpos + animationWidth) == (posX + pWidth)))
      input_flags[0] = 1;
  }
  
  if(direction == "h1") {
    //Rectangle left edge with character left edge
    if((xpos < posX) || (xpos == posX )) 
      input_flags[1] = 1;
    //Rectangle right edge with character right edge
    if(((xpos + animationWidth) > (posX + pWidth))||((xpos + animationWidth) == (posX + pWidth)))
      input_flags[0] = 1; 
    //Rectangle uppper edge with character upper edge. Case which the left upper part is open
    if(((ypos < posY) || (ypos == posY)) && (xpos > (posX + pHeight)))
      input_flags[2] = 1;
    //Rectangle lower edge with character lower edge. Case which the lower right is open
    if((((ypos + animationHeight) > (posY + pHeight))||((ypos + animationHeight) == (posY + pHeight))) && ((xpos + animationWidth) < (posX + pWidth - pHeight)))
      input_flags[3] = 1;
  }
  
  if(direction == "h2"){
    //Rectangle left edge with character left edge
    if((xpos < posX) || (xpos == posX )) 
      input_flags[1] = 1;
    //Rectangle right edge with character right edge
    if(((xpos + animationWidth) > (posX + pWidth))||((xpos + animationWidth) == (posX + pWidth)))
      input_flags[0] = 1; 
    //Rectangle uppper edge with character upper edge. Case which the upper right part is open
    if(((ypos < posY) || (ypos == posY)) && ((xpos + animationWidth) < (posX + pWidth - pHeight)))
      input_flags[2] = 1;
    //Rectangle lower edge with character lower edge. Case which the lower left is open
    if((((ypos + animationHeight) > (posY + pHeight))||((ypos + animationHeight) == (posY + pHeight))) && (xpos > (posX + pHeight)))
      input_flags[3] = 1;
  }
  
  if(direction == "h3"){
    //Rectangle left edge with character left edge
    if((xpos < posX) || (xpos == posX )) 
      input_flags[1] = 1;
    //Rectangle right edge with character right edge
    if(((xpos + animationWidth) > (posX + pWidth))||((xpos + animationWidth) == (posX + pWidth)))
      input_flags[0] = 1; 
    //Rectangle uppper edge with character upper edge. Case which the upper right part is open
    if(((ypos < posY) || (ypos == posY)) && ((xpos + animationWidth) < (posX + pWidth - pHeight)))
      input_flags[2] = 1;
    //Rectangle lower edge with character lower edge
    if(((ypos + animationHeight) > (posY + pHeight))||((ypos + animationHeight) == (posY + pHeight)) )
      input_flags[3] = 1;
  }
  
  if(direction == "h4") {
    //Rectangle left edge with character left edge
    if((xpos < posX) || (xpos == posX )) 
      input_flags[1] = 1;
    //Rectangle right edge with character right edge
    if(((xpos + animationWidth) > (posX + pWidth))||((xpos + animationWidth) == (posX + pWidth)))
      input_flags[0] = 1; 
    //Rectangle uppper edge with character upper edge. Case which the left upper part is open
    if(((ypos < posY) || (ypos == posY)) && (xpos > (posX + pHeight)))
      input_flags[2] = 1;
    //Rectangle lower edge with character lower edge
    if(((ypos + animationHeight) > (posY + pHeight))||((ypos + animationHeight) == (posY + pHeight)) )
      input_flags[3] = 1;
  }   
  
}

int[] getInputs(){
 return input_flags; 
}

}
